﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Media;
using jaam_butters.Agents;

    
namespace jaam_butters.Ground
{
    
    class GroundGrid : DrawableGameComponent
    {
        SpriteBatch spriteBatch; 
        DrawableGameComponent[,] gameGrid = new DrawableGameComponent[5,5];
        int tileHeight = 120;
        int tileWidth = 120;
        Game game;
        Jaam myJaam;
        Vector2 Position;

        public GroundGrid(Game g, Vector2 position,Jaam jaam,SpriteBatch sb)
            : base(g)
        {
           
            spriteBatch = sb;
            myJaam = jaam;
            game = g;
            Position = position;
            for(int i=0;i<5;i++)
            {
                for(int j=0;j<5;j++)
                {
                    gameGrid[i,j]=new GoodGround(g,Position + new Vector2(j*tileWidth,i*tileHeight),spriteBatch);
                }
            }
            gameGrid[4,3] = new EvilGround(g,Position + new Vector2(3*120,4*120),myJaam,spriteBatch);
            gameGrid[2, 3] = new EvilGround(g, Position + new Vector2(3 * 120, 2 * 120), myJaam,spriteBatch);
            gameGrid[1, 3] = new EvilGround(g, Position + new Vector2(3 * 120, 1 * 120), myJaam,spriteBatch);
            gameGrid[1, 2] = new EvilGround(g, Position + new Vector2(2 * 120, 1 * 120), myJaam,spriteBatch);
            gameGrid[1, 1] = new EvilGround(g, Position + new Vector2(1 * 120, 1 * 120), myJaam,spriteBatch);
            gameGrid[3, 1] = new EvilGround(g, Position + new Vector2(1 * 120, 3 * 120), myJaam,spriteBatch);

            gameGrid[4, 4] = new CoffeeGround(g, Position + new Vector2(120 * 4 , 120 * 4),myJaam,spriteBatch);

        }
        public override void Initialize()
        {
            foreach (DrawableGameComponent i in gameGrid) i.Initialize();
            base.Initialize();
        }
        protected override void LoadContent()
        {
            base.LoadContent();
        }
        public override void Draw(GameTime gameTime)
        {
            
            foreach (DrawableGameComponent i in gameGrid) i.Draw(gameTime);
            //base.Draw(gameTime);
            
        }
        public override void Update(GameTime gameTime)
        {
            foreach (DrawableGameComponent i in gameGrid) i.Update(gameTime);
            //base.Update(gameTime);
        }
       
    }
}
